import {
    getVerify,
    checkVerify
} from '@/services/verifyCode'
export default {
    namespace: 'VerifyCode',
    state: {
        getVerify: {},
        checkVerify: {},
    },

    effects: {
        *getVerify({ payload, callback }, { call, put }) {
            const response = yield call(getVerify, payload)
            if(response.repCode!=='0000') return
            yield put({
                type: 'saveAllValus',
                payload: {
                    getVerify:response.repData
                },
            });
            if (callback) callback(response);
        },
        *checkVerify({ payload, callback }, { call, put }) {
            const response = yield call(checkVerify, payload)
            yield put({
                type: 'saveAllValus',
                payload: {
                    checkVerify:response.repData
                },
            });
            if (callback) callback(response);
        },

    },

    reducers: {
        saveAllValus(state, { payload }) {
            return {
                ...state,
                ...payload,
            };
        },

    },
};
